home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Wayzata's Best of Shareware PC/Windows 1
/
Wayzata's Best of Shareware for PC-Windows - Release 1 - Wayzata Technology (1993).iso
/
mac
/
DOS
/
PROGRAMG
/
QLIB56
/
COMPLEX.DOC
next >
Wrap
Text File
|
1991-11-29
|
4KB
|
131 lines
************************* COMPLEX DATA TYPE *******************************
QLIB's COMPLEX data type is modeled after the COMPLEX data type in
PC FORTRAN compilers. COMPLEX data is 8 bytes long, and consists of
paired SINGLE values. The low 4 bytes represent the real part of the
complex value, and the high 4 bytes represent the imaginary part of the
number. For allocating arrays, copying values or several other operations,
you may use BASIC and you should treat COMPLEX data as though it were
DOUBLE. For calculation or data type conversion, use QLIB. QLIB's
COMPLEX subroutines use the 80x87 if present, or use BASIC's 8087 emulator
otherwise. As I have done limited testing with non-8087 equipped computers,
I suggest that you save your work before running any COMPLEX subroutines
from within the QuickBASIC enviornment. Where 80x87 emulation is
indicated, I have had no problems (except for speed!!) running stand-alone
.EXE programs on computers without a math coprocessor.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: CPX2Real(cpx#, r!, i!)
Object file: complex.obj
80x87 not required
CPX2Real splits a COMPLEX value into its real and imaginary components.
Note that the components are 4-byte SINGLE data, while the complex value
is 8 bytes long.
Example:
REM cpx# is a complex value computed by QLIB earlier in the program
CALL CPX2Real(cpx#, r!, i!)
PRINT "The real part of cpx# is ", r!
PRINT "The imaginary part of cpx# is ", i!
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: c3# = CPXAdd#(c0#, c1#)
Object file: complex.obj
80x87 not required; uses BASIC's emulator
CPXAdd add two complex numbers. c0# and c1# must be valid COMPLEX values.
Example:
REM $INCLUDE: 'qlib.bi'
.
.
.
REM the values of c0# and c1# were established earlier in the program
c2# = CPXAdd(c0#, c1#)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: c2# = CPXDiv(c0#, c1#)
Object file: complex.obj
80x87 not required; uses BASIC's emulator
CPXDiv divides c0# by c1#, returning the result in c2#. c0# and c1#
must be valid COMPLEX numbers.
Example:
REM $INCLUDE: 'qlib.bi'
.
.
.
REM the values of c0# and c1# were established earlier in the program
c2# = CPXDiv(c0#, c1#)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: c2# = CPXMul(c0#, c1#)
Object file: complex.obj
80x87 not required; uses BASIC's emulator
CPXMul multiplies c0# and c1#, returning the product in c2#. c0# and c1#
must be valid COMPLEX numbers.
Example:
REM $INCLUDE: 'qlib.bi'
.
.
.
REM the values of c0# and c1# were established earlier in the program
c2# = CPXMul(c0#, c1#)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: c1# = CPXNeg(c0#)
Function: c1# = CPXNegI(c0#)
Function: c1# = CPXNegR(c0#)
Object file: complex.obj
80x87 not required
CPXNeg changes the sign of c0#'s real and imaginary parts. CPXNegI
changes the sign of only the imaginary part of c0#, and CPXNegR changes
the sign of only the real part of c0#. In all cases, c0# is unchanged
and the result is returned in c1#.
Example:
REM $INCLUDE: 'qlib.bi'
.
.
.
c1# = CPXNeg(c0#)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: cpx# = Real2CPX(r!, i!)
Object file: complex.obj
80x87 not required
Real2CPX forms a COMPLEX value from the component real and imaginary
parts. Note that r! and i! are 4-byte SINGLE values, and cpx# is 8
bytes long.
Example:
REM $INCLUDE: 'qlib.ib' ' has Real2CPX function declaration
r! = 3.678!: i! = -.0987 ' the number 3.678-.0987i
cpx# = Real2CPX(r!, i!)